﻿using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using CE.User;
using CE.Global;
using CE.Database;
using CE.CarInsurance;
using CE.Company;
using CE.Mail;
using CE.InputOut;

public partial class Quote_Result_Detail : MyLanguageBasePage
{
    string _redirectUrl = "";
    protected void Page_Init(object sender, EventArgs e)
    {
        GetResultDetails();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            //btnEmail.Attributes.Add("onclick", "return confirm('Are you sure you want to send this quote?');");
            imgEmailQuote.Attributes.Add("onclick", "return confirm('Are you sure you want to send this quote?');");


        }

    }

    private void GetResultDetails()
    {
        string qs_carselected = "";

        if (Request.QueryString["crid"] != null)
        {
            qs_carselected = Request.QueryString["crid"].ToString();
        }

        if (qs_carselected != "" && Session[General.UserId] != null && Session[General.CarId] != null && Session[General.UserName] != null)
        {
            if (Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()] != null)
            {
                DataView dv = new DataView((DataTable)Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()]);

                string CITempResultId = qs_carselected; // Session["CarSelected"].ToString();

                //dv.RowFilter = " CITempResultId in (" + CITempResultId.Remove(CITempResultId.Length - 1, 1) + ")";
                dv.RowFilter = " CITempResultId in (" + CITempResultId + ")";
                DataTable dtFiltered = dv.ToTable();
                if (Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()] != null)
                {
                    if (dtFiltered.Rows.Count > 0)
                    {
                        int rowCount = dtFiltered.Rows.Count;

                        lblCarResultID.Text = CITempResultId;

                        for (int iRows = 0; iRows < rowCount; iRows++)
                        {
                            string _makemodel = "";
                            string _garagetype = "";
                            string _caryear = "";
                            string _ncb = "";
                            string _policystartdate = "";

                            Int64 _cecarid = 0;

                            if (Session[General.CarPolicyId] != null && Session[General.CarId] != null)
                            {
                                _cecarid = Convert.ToInt64(Session[General.CarId]);
                                Int64 _cepolicyid = Convert.ToInt64(Session[General.CarPolicyId]);
                                Int64 _userId = 0;

                                if (Session[General.UserId] != null)
                                {
                                    _userId = Convert.ToInt64(Session[General.UserId].ToString());
                                }

                                CarDetailTH _cardetail = new CarDetailTH();
                                CarDetailTHDB _cardetaildb = new CarDetailTHDB();
                                _cardetail = _cardetaildb.GetCar(_cecarid, _userId);

                                CarPolicy _carpolicy = new CarPolicy();
                                CarPolicyDB _carpolicydb = new CarPolicyDB();
                                _carpolicy = _carpolicydb.GetCarPolicy(_cecarid, _cepolicyid, _userId);

                                if (_cardetail != null)
                                {
                                    _makemodel = _cardetail.CarModelName + " " + _cardetail.Body + " " + _cardetail.CC + "cc " + _cardetail.Door.ToString() + " doors";
                                    _caryear = _cardetail.ManufactYear.ToString();
                                }

                                if (_carpolicy != null)
                                {
                                    _garagetype = _carpolicy.GarageType.ToString();
                                    _ncb = _carpolicy.NCDPercent.ToString();
                                    _policystartdate = _carpolicy.CoverageCommenceDate.ToString("dd/MMM/yyyy");
                                }

                                if (_garagetype.Trim() == "1")
                                    lblGarage.Text = Resources.CarInsurance.Garage_Authorized;
                                else
                                    lblGarage.Text = Resources.CarInsurance.Garage_Dealer;

                                lblMakeModel.Text = _makemodel;
                                lblCarYear.Text = _caryear;
                                lblPolicyDate.Text = _policystartdate;
                                lblNCB.Text = _ncb + "%";
                                lblQuoteDate.Text = DateTime.Now.ToString("dd/MMM/yyyy");
                            }

                            //string convertno = General.GetRefNumber(_cecarid);                           
                            string _providercompanyid = dtFiltered.Rows[iRows]["ProviderCompanyId"].ToString();
                            //string convertno = General.GetReferenceNumber(_cecarid.ToString(), _providercompanyid);
                            lblRefNo.Text = General.GetReferenceNumber(_cecarid.ToString(), _providercompanyid);

                            if (Session["Language"] != null)
                            {
                                if (Session["Language"].ToString() == "th-TH")
                                    lblInsurer.Text = General.GetProviderName(int.Parse(_providercompanyid), "1");
                                else
                                    lblInsurer.Text = General.GetProviderName(int.Parse(_providercompanyid), "2");
                            }
                            else
                            {
                                //english
                                lblInsurer.Text = General.GetProviderName(int.Parse(_providercompanyid), "2");
                            }
                            

                            imgInsurer.ImageUrl = "http://www.gluaygluay.com/" + CE.Global.General.GetProviderCompanyLogo(_providercompanyid);
                            imgInsurer.Width = 120;

                            //hlnkProvider.NavigateUrl = "provider_detail.aspx?pid=" + _providercompanyid;
                            
                            //PlanName
                            lblPackage.Text = "<strong>" + dtFiltered.Rows[iRows]["packagename"].ToString() + "</strong>";

                            //Premium
                            string annualprice = string.Empty;
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"]) != Convert.ToSingle(dtFiltered.Rows[iRows]["promotionprice"]))
                            {
                                annualprice = "<s>" + String.Format("{0:0,0.00}", Convert.ToSingle(dtFiltered.Rows[iRows]["annualpremium"].ToString())) + "</s>";
                            }
                            //annualprice = annualprice + "<div class=price><img src='/images/other/spacer.gif' alt='Only Online!' width='45' height='1'/>";
                            annualprice = annualprice + "<div style='color:#F00;font-size:20px;font-weight:bold;'>";
                            annualprice = annualprice + String.Format("{0:0,0.00}", Convert.ToSingle(dtFiltered.Rows[iRows]["promotionprice"].ToString())); //"999.00";
                            annualprice = annualprice + "</div>";
                            //annualprice = annualprice + "<br/><img src='" + Resources.ImageResource .OnlineOnlyUrl +"' alt='Only Online!' width='45' height='30'/>";

                            lblPrice.Text = annualprice;

                            //string _promotion = DataBinder.Eval(e.Row.DataItem, "PromotionPrice").ToString().Trim();
                            //string _premium = DataBinder.Eval(e.Row.DataItem, "AnnualPremium").ToString().Trim();

                            //Label lblPromotionPrice = (Label)e.Row.FindControl("lblPromotionPrice");
                            //Label lblPremiumPrice = (Label)e.Row.FindControl("lblPremiumPrice");

                            //lblPromotionPrice.Text = Convert.ToSingle(_promotion).ToString("#,000.00");
                            //if (_promotion != _premium)
                            //{
                            //    lblPremiumPrice.Text = Convert.ToSingle(_premium).ToString("#,000.00");
                            //}

                            //Installment
                            #region Installment

                            //HtmlTableCell tcInstallment = new HtmlTableCell();
                            //tcInstallment.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");

                            //float _fMonthlyPremiumAmount = Convert.ToSingle(dtFiltered.Rows[iRows]["MonthlyPremiumAmount"].ToString());

                            //if (_fMonthlyPremiumAmount > 0.0f)
                            //{
                            //    string _monthlyPremiumAmount = String.Format("{0:0,0.00}", _fMonthlyPremiumAmount);

                            //    tcInstallment.InnerHtml = _monthlyPremiumAmount + "/mth<br/>";

                            //}
                            //else
                            //{
                            //    Image imgInstallment = new Image();
                            //    imgInstallment.ImageUrl = "/images/icon/X.png";
                            //    tcInstallment.Controls.Add(imgInstallment);
                            //}

                            //trInstallment.Controls.Add(tcInstallment);

                            #endregion

                            //Deductible- Excess
                            String dec = string.Empty;
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["DEC"].ToString()) == 0)
                            {
                                dec = Resources.CarInsuranceResultPage.Waived;
                            }
                            else
                            {
                                dec = String.Format("{0:0,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["DEC"].ToString()));
                            }
                            lblExcess.Text = dec;

                            //SumInsured - OwnDamange
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["SumInsured"].ToString()) == 0)
                            {                                
                                imgDamage.Visible = true;
                                imgDamage.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                            else
                            {
                                lblDamage.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["SumInsured"].ToString()));
                            }

                            //Fire
                            HtmlTableCell tcPA = new HtmlTableCell();
                            tcPA.Attributes.Add("class", "bg_grey_2 pad7px");
                            if (Convert.ToInt32(dtFiltered.Rows[iRows]["Fire"].ToString()) == 0)
                            {
                                imgFire.Visible = true;
                                imgFire.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                            else
                            {
                                lblFire.Text = String.Format("{0:#,0}", Convert.ToInt32(dtFiltered.Rows[iRows]["Fire"].ToString()));
                            }


                            //Theft
                            HtmlTableCell tcPA2 = new HtmlTableCell();
                            tcPA2.Attributes.Add("class", "bg_grey_3 border1pxdotb_light pad7px");
                            if (Convert.ToSingle(dtFiltered.Rows[iRows]["Theft"].ToString()) == 0)
                            {
                                imgTheft.Visible = true;
                                imgTheft.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                            else
                            {
                                lblTheft.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["Theft"].ToString()));
                            }

                            //MEdical Expense
                            lblMedExp.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPPD"].ToString()));
                            #region remove
                            //int _MedicalExpense = Convert.ToInt32(dtFiltered.Rows[iRows]["SumInsured"].ToString());

                            //if (_MedicalExpense == 0)
                            //{
                            //    Image imgMedExp = new Image();
                            //    imgMedExp.ImageUrl = "~/images/icon/X.png";
                            //    tcMedExp.Controls.Add(imgMedExp);
                            //}
                            //else
                            //{
                            //    tcMedExp.InnerText = String.Format("{0:#,0}", Convert.ToSingle(_MedicalExpense.ToString()));
                            //}

                            //trMedExp.Controls.Add(tcMedExp);
                            #endregion

                            //Loss of Personal Effects
                            lblLossPE.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPBIA"].ToString()));

                            #region remove
                            //bool _IsPersonnalEffectsLoss = Convert.ToBoolean(dtFiltered.Rows[iRows]["IsPersonnalEffectsLoss"].ToString());

                            //if (!_IsPersonnalEffectsLoss)
                            //{
                            //    Image imgLossPE = new Image();
                            //    imgLossPE.ImageUrl = "~/images/icon/X.png";
                            //    tcLossPE.Controls.Add(imgLossPE);
                            //}
                            //else
                            //{
                            //    tcLossPE.InnerText = String.Format("{0:#,0}", Convert.ToSingle(_LossPE.ToString()));
                            //}

                            //trLossPE.Controls.Add(tcLossPE);
                            #endregion
                            //Loss of Use
                            lblLossUse.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["TPBIP"].ToString()));

                            #region remove
                            //string _CarReplace =  dtFiltered.Rows[iRows]["CarReplacement"].ToString();
                            //bool _IsCarReplace =  Convert.ToBoolean(dtFiltered.Rows[iRows]["IsCarReplacement"].ToString());
                            //bool _IsTranspoAllowance  = Convert.ToBoolean(dtFiltered.Rows[iRows]["isCashAllowance"].ToString());
                            //string _strTranspoAllowance  = Convert.ToString(dtFiltered.Rows[iRows]["CashAllowance"].ToString());
                            //string _strMaxTranspoAllowanceDays = Convert.ToString(dtFiltered.Rows[iRows]["MaxCashAllowanceDays"].ToString());

                            //if (_IsCarReplace)
                            //{
                            //    tcLossUse.InnerHtml = "Courtesy Car <br/>" + "max " + _CarReplace.ToString() + " day(s)";
                            //}
                            //else
                            //{
                            //    if (_IsTranspoAllowance)
                            //    {
                            //        tcLossUse.InnerHtml = "Transport Allowance<br/> S$" + _strTranspoAllowance + "/day <br/> max " + _strMaxTranspoAllowanceDays + " day(s)";
                            //    }
                            //    else
                            //    {
                            //        Image imgCarRep = new Image();
                            //        imgCarRep.ImageUrl = "~/images/icon/X.png";
                            //        tcLossUse.Controls.Add(imgCarRep);
                            //    }

                            //}

                            //trLossOfUse.Controls.Add(tcLossUse);
                            #endregion

                            //workshops pdf
                            lblWorkshopPDF.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["PADriver"].ToString()));

                            #region remove
                            //Image imgWorkshops = new Image();
                            //HyperLink hlnkWorkshop = new HyperLink();
                            //hlnkWorkshop.ImageUrl = "~/images/icon/pdf.png";
                            //hlnkWorkshop.Target = "blank";

                            //if (_providercompanyid == "29")
                            //{
                            //    hlnkWorkshop.NavigateUrl = "http://www.libertyinsurance.com.sg/pdf/PWS%20Nov05.pdf";
                            //}
                            //else if (_providercompanyid == "30")
                            //{
                            //    hlnkWorkshop.NavigateUrl = "../policy_docs/Etiqa/Etiqa - AWS Listing.pdf";
                            //}
                            //else
                            //{
                            //    hlnkWorkshop.NavigateUrl = "../policy_docs/HSBC/HSBCworkshops.pdf";
                            //    //hlnkWorkshop.NavigateUrl = "javascript:OpenWorkshop(" + _providercompanyid.ToString() + ");";
                            //}

                            //tcWorkshopPDF.Controls.Add(hlnkWorkshop);

                            //trWorkshopPDF.Controls.Add(tcWorkshopPDF);
                            #endregion
                            // policy
                            lblPolicy.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["MedicalExpense"].ToString()));

                            #region remove
                            //string _policyId = "test";// dtFiltered.Rows[iRows]["NInfo1"].ToString();

                            //ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
                            //ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

                            ////_policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

                            //string docurl = _policydoc.UploadPath;
                            //HyperLink _lnkTest = new HyperLink();
                            //_lnkTest.NavigateUrl = docurl;

                            //HyperLink hplnkPolicyDoc = new HyperLink();
                            //hplnkPolicyDoc.ImageUrl = "~/images/icon/pdf.png";
                            //hplnkPolicyDoc.NavigateUrl = _lnkTest.ResolveClientUrl(docurl);
                            //hplnkPolicyDoc.Target = "_blank";

                            //tcPolicyPDF.Controls.Add(hplnkPolicyDoc);
                            //trPolicy.Controls.Add(tcPolicyPDF);
                            #endregion

                            //endorsements
                            lblEndorsement.Text = String.Format("{0:#,0}", Convert.ToSingle(dtFiltered.Rows[iRows]["BailBond"].ToString()));

                            #region remove
                            //HyperLink hlnkEndorsements = new HyperLink();
                            //hlnkEndorsements.ImageUrl = "~/images/icon/pdf.png";
                            //hlnkEndorsements.Target = "_blank";

                            //int _coverid = Convert.ToInt32(dtFiltered.Rows[iRows]["CoverTypeId"].ToString());

                            //if (_providercompanyid == "23")
                            //{
                            //    if (_coverid == 2 || _coverid == 6) //classic
                            //    {
                            //        hlnkEndorsements.NavigateUrl = "~/policy_docs/HSBC/PCIClassicPlan.pdf";
                            //    }
                            //    else
                            //    {
                            //        hlnkEndorsements.NavigateUrl = "~/policy_docs/HSBC/PCIPremierPlan.pdf";
                            //    }

                            //    tcEndorsement.Controls.Add(hlnkEndorsements);
                            //}

                            //trEndorsement.Controls.Add(tcEndorsement);
                            #endregion

                            if (dtFiltered.Rows[iRows]["IsFloodCover"].ToString() == "0")
                            {
                                imgFlood.ImageUrl = "http://www.comparexpress.com/images/icon/X.png";
                            }
                            else
                            {
                                imgFlood.ImageUrl = "http://www.gluaygluay.com/images/icon/flood_car.png";
                            }

                            //string _citempresultid = dtFiltered.Rows[iRows]["CITempResultId"].ToString();
                            


                        }

                    }
                }
            }
            else
            {
                Response.Redirect("quote_result.aspx");
            }
        }
        else
        {
            Response.Redirect("quote_result.aspx");
        }

    }

    protected void imgEmailQuote_Click(object sender, ImageClickEventArgs e)
    {
        string _emailList = "", _title = "";
        System.Text.StringBuilder _message = new System.Text.StringBuilder();
        _emailList = Session[CE.Global.General.UserEmail].ToString();
        //_emailList += ";team@comparexpress.com";
        //string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString() + "/";
        string _currentDomainUrl = "http://www.gluaygluay.com/";
        _title = "";

        _title = "gluaygluay.com (Ref No : " + lblRefNo.Text + ")";

        _message.Append("<table cellpadding='0' cellspacing='0' border='0' width='240' style='font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0 auto;'>");
        _message.Append("<tr><td style='border-bottom:1px solid #ccc;' align='center'><img src='" + _currentDomainUrl + "mobile/images/bg/logo_gluaygluay.png' alt='' height='78' /><br/><br/>");
        _message.Append("Thank you for choosing GluayGluay.com <br/><strong>Here is your Quote Details </strong><br /><br/></td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><br /><table cellspacing='0' cellpadding='2' width='100%' border='0'>");

        _message.Append("<tr><td valign='top'>" + Resources.ProposalForm.QuoteReferenceNumber + "</td>");
        _message.Append("<td valign='top'><strong><u>" + lblRefNo.Text + "</u></strong></td></tr>");

        _message.Append("<tr><td width='50%' valign='top'> " + Resources.ProposalForm.GarageType + " </td>");
        _message.Append("<td width='50%' valign='top'><strong>" + lblGarage.Text + "</strong></td></tr>");

        _message.Append("<tr><td valign='top'>" + Resources.ProposalForm.CarMakeModel + "</td>");
        _message.Append("<td valign='top'><strong>" + lblMakeModel.Text + "</strong></td></tr>");

        _message.Append("<tr><td valign='top'>" + Resources.ProposalForm.CarModelYear + "</td>");
        _message.Append("<td valign='top'><strong>" + lblCarYear.Text + "</strong></td></tr>");

        _message.Append("<tr><td valign='top'>" + Resources.ProposalForm.CoverCommencementDate + "</td>");
        _message.Append("<td valign='top'><strong>" + lblPolicyDate.Text + "</strong></td></tr>");

        _message.Append("<tr><td valign='top'>" + Resources.ProposalForm.NCB + "</td>");
        _message.Append("<td valign='top'><strong>" + lblNCB.Text + "</strong></td></tr>");

        _message.Append("<tr><td valign='top'> " + Resources.ProposalForm.QuoteDate + "</td>");
        _message.Append("<td valign='top'><strong>" + lblQuoteDate.Text + "</strong></td></tr>");

        _message.Append("</table><br /></td></tr><tr><td width='300'><br />");

        _message.Append("<table width='100%' border='0' cellpadding='5' cellspacing='0'  class='table_details'>");

        _message.Append("<tr><td width='45%'></td>");
        _message.Append("<td width='55%' align='center' style='background:#e0e0e0; border-bottom:white 1px dashed;'>");
        _message.Append("<img src='" + imgInsurer.ImageUrl + "'  width='120px' /></td></tr>");

        _message.Append("<tr><td><strong>" + Resources.CarInsuranceResultPage.Insurer + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5; color:black;' ><strong>" + lblInsurer.Text + "</strong></td></tr>");

        _message.Append("<tr><td></td>");
        _message.Append("<td align='center' style='background:#d5d5d5;'>" + lblPackage.Text + "</td></tr>");

        _message.Append("<tr><td align='left' style='background:#d5d5d5' ><strong>" + Resources.CarInsuranceResultPage.TotalVMI + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5; color:black; font-size:16px;'><strong>" + lblPrice.Text + "</strong></td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.DEC + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >" + lblExcess.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.OwnDamage + "</strong></td>");
        _message.Append("<td align='center' style='background:#c5c5c5;'>");

        if (imgDamage.Visible)
            _message.Append("<img src='" + _currentDomainUrl + imgDamage.ImageUrl + "' /></td></tr>");
        else
            _message.Append(lblDamage.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.Fire + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");

        if (imgFire.Visible)
            _message.Append("<img src='" + _currentDomainUrl + imgFire.ImageUrl + "' /></td></tr>");
        else
            _message.Append(lblFire.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.Theft + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");

        if (imgTheft.Visible)
            _message.Append("<img src='" + _currentDomainUrl + imgTheft.ImageUrl + "' /></td></tr>");
        else
            _message.Append(lblTheft.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.TPPD + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblMedExp.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.TPBIA + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblLossPE.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.TPBIP + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblLossUse.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.PADriver + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblWorkshopPDF.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.MED + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblPolicy.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.BailBond + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append(lblEndorsement.Text + "</td></tr>");

        _message.Append("<tr><td style='border-bottom:1px solid #ccc;'><strong>" + Resources.CarInsuranceResultPage.FloodCover + "</strong></td>");
        _message.Append("<td align='center' style='background:#d5d5d5' >");
        _message.Append("<img src='" + imgFlood.ImageUrl + "' /></td></tr>");

        _message.Append("</table><br /><br />");
        _message.Append("<a href='tel:022688222'><img src='http://www.gluaygluay.com/images/banners/hotline_en.png' alt='Call Us at 02 268 8222' width='240' border='0' /></a>");
        _message.Append("<br /><br /><br />");

        _message.Append("<strong>" + Resources.ProposalForm.Remarks + "</strong><br />");
        _message.Append(Resources.ProposalForm.RemarkOne + "<br />");
        _message.Append(Resources.ProposalForm.RemarkTwo + "<br />");
        _message.Append("</td></tr><tr><td id='email_footer'></td>");
        _message.Append("</tr></table><br /><br /><hr />" + Resources.ProposalForm.ThisQuoteis + " <br /><br />");
        _message.Append("<i>" + Resources.ProposalForm.EmailDisclaimer + "</i><hr />");

        MyMailManager.SendNotification(_emailList, _title, _message.ToString());
        Response.Redirect("email_confirm.aspx?type=email&resultid=" + lblCarResultID.Text);
    }

    protected void btnEmailThis_Click(object sender, CommandEventArgs e)
    {
        string _providerID = "";
        string _carresultID = "";
        string[] _ids = e.CommandArgument.ToString().Split(',');

        _providerID = _ids[0].ToString();
        _carresultID = _ids[1].ToString();

        Session[CE.Global.General.CarResultId] = _carresultID;
        //Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["FromSummary"] = "0";

        _redirectUrl = "email_confirm.aspx";
        Response.Redirect(_redirectUrl);

    }

    protected void btnBuyNow_Click(object sender, CommandEventArgs e)
    {
        string _providerID = "";
        string _carresultID = "";
        string[] _ids = e.CommandArgument.ToString().Split(',');

        _providerID = _ids[0].ToString();
        _carresultID = _ids[1].ToString();

        CarDetailTHDB cardetail = new CarDetailTHDB();
        Boolean language = cardetail.UpdateLanguage(Convert.ToInt64(Session[General.CarId]), Session["Language"].ToString());

        Session[CE.Global.General.CarResultId] = _carresultID;
        //Session[CE.Global.General.ProviderCompanyId] = _providerID;
        Session["FromSummary"] = "0";
        //CarUserOptionLog(true, false, false);
       // _redirectUrl = CE.Global.General.GetProviderProposalUrl(_providerID, Page);
        Response.Redirect(_redirectUrl);

    }
}
